// ==UserScript==
// @name         素材网去水印
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @description  去除素材网的水印。目前支持图怪兽、千图网、创客贴、稿定设计、比格设计。
// @author       cangming99
// @match        https://ue.818ps.com/*
// @match        https://ecommerce.818ps.com/*
// @match        https://designer-ue.58pic.com/*
// @match        https://www.gaoding.com/editor/*
// @match        https://beta.chuangkit.com/odyssey/design*
// @match        https://bigesj.com/bill/*
// @icon         
// @grant        none
// @license MIT
// @downloadURL https://update.greasyfork.org/scripts/486214/%E7%B4%A0%E6%9D%90%E7%BD%91%E5%8E%BB%E6%B0%B4%E5%8D%B0.user.js
// @updateURL https://update.greasyfork.org/scripts/486214/%E7%B4%A0%E6%9D%90%E7%BD%91%E5%8E%BB%E6%B0%B4%E5%8D%B0.meta.js
// ==/UserScript==

(function () {
    'use strict';

    // 创建按钮样式
    const buttonStyle = `
        --as-text-color-secondary: #909399;
        --as-horizontal-height: $height;
        --as-primary-color: #1890ff;
        --as-bg-color: #ffffff;
        --as-primary-text-color: #606266;
        --as-secondary-background-color: #f5f7fa;
        --as-border-color: #e8e8e8;
        border-width: 0px;
        pointer-events: auto;
        margin: 0;
        padding: 0;
        user-select: none;
        text-decoration: none;
        color: #7a4806;
        cursor: pointer;
        font-family: PingFangSC-Medium, PingFang SC;
        font-size: 14px;
        font-weight: 500;
        height: 40px;
        line-height: 40px;
        position: absolute;
        text-align: center;
        background: linear-gradient(90deg, #fdf6e4, #eddeb7);
        border-radius: 5px 5px 5px 5px;
        bottom: 110px;
        box-shadow: 0 0 4px 0 #00000026;
        box-sizing: border-box;
        left: 40%;
        transform: none;
        width: 80px;
        z-index: 99999;
        top: 10px;
        display: inline-block;
    `;

    function addButton() {
        // 创建按钮
        const button = document.createElement('button');
        button.innerHTML = '去水印';
        button.style.cssText = buttonStyle;

        // 将按钮添加到页面
        document.body.appendChild(button);

        // 点击按钮后执行隐藏水印的操作
        button.addEventListener('click', removeWatermark);
    }

    function removeWatermark() {
        // 图怪兽和千图网直接移除水印元素
        if (window.location.href.includes('818ps') || window.location.href.includes('58pic')) {
            document.querySelectorAll('.image-watermark').forEach(element => element.remove());
        }
        // 稿定设计将图层置顶，覆盖水印
        else if (window.location.href.includes('gaoding.com/editor/')) {
            document.querySelectorAll('.editor-element, .editor-background').forEach(element => element.style.zIndex = '99999');
        }
        // 创客贴去除多余按钮，将图层置顶，覆盖水印
        else if (window.location.href.includes('beta.chuangkit.com/odyssey/design')) {
            // 移除去水印按钮
            const removeButton = document.querySelector('.remove-cktTemplate-watermark');
            if (removeButton) {
                removeButton.remove();
            }
            // 置顶图层
            const canvasSlotItem = document.querySelector('.canvas-slot-item');
            if (canvasSlotItem) {
                canvasSlotItem.style.zIndex = '99999';
                canvasSlotItem.style.position = 'absolute';
            }
        }
        // 比格设计，直接移除水印和按钮
        else if (window.location.href.includes('bigesj.com/bill/')) {
            document.querySelectorAll('.water').forEach(element => element.remove());
            document.querySelectorAll('.water-tip').forEach(element => element.remove());
        }
    }

    window.addEventListener('load', addButton);
})();
